package com.demo;

import com.demo.mapper.UserMapper;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author shenguangyang
 */
public class DemoApplication {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class);
//        applicationContext.register(AppConfig.class);
//
//        AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition().getBeanDefinition();
//        beanDefinition.setBeanClass(MyFactoryBean.class);
//        beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(UserMapper.class);
//        applicationContext.registerBeanDefinition("userMapper", beanDefinition);
//        applicationContext.refresh();

        UserMapper userMapper = applicationContext.getBean(UserMapper.class);
        System.out.println(userMapper.getUserName());
    }
}
